package com.indusfo.spc.controller;

import com.indusfo.spc.aspect.SystemControllerLog;
import com.indusfo.spc.pojo.Inspect;
import com.indusfo.spc.service.InspectService;
import com.indusfo.spc.vo.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 设备点检项目控制层
 */

@Controller
@RequestMapping("/service/inspect")
public class InspectController {

    @Autowired
    private InspectService inspectService;

    /**
     * 编辑
     *
     * @param inspect
     * @return com.indusfo.spc.vo.JSONObject
     */
    @RequestMapping(value = "/updateInspect",method= RequestMethod.POST)
    @SystemControllerLog(description="编辑点检项目")
    @ResponseBody
    public JSONObject updateInspect (Inspect inspect){
        JSONObject json=inspectService.updateInspect(inspect);
        return json;
    }

    /**
     * 查询
     *
     * @param inspect
     * @return com.indusfo.spc.vo.JSONObject
     */
    @RequestMapping(value="/queryInspect")
    @SystemControllerLog(description="查询点检项目")
    @ResponseBody
    public JSONObject queryInspect(Inspect inspect) {
        JSONObject json = inspectService.selectAll(inspect);
        return json;

    }

    /**
     * 新增
     *
     * @param inspect
     * @return com.indusfo.spc.vo.JSONObject
     */
    @RequestMapping(value="/insertInspect", method= RequestMethod.POST)
    @SystemControllerLog(description="新增点检项目")
    @ResponseBody
    public JSONObject insertInspect(Inspect inspect) {
        JSONObject json = inspectService.insertInspect(inspect);
        return json;
    }

    /**
     * 启用/停用
     *
     * @param inspectIds, dataState
     * @return com.indusfo.spc.vo.JSONObject
     */
    @RequestMapping(value="/definedInspect", method= RequestMethod.POST)
    @SystemControllerLog(description="启用/停用点检项目")
    @ResponseBody
    public JSONObject definedInspect(Long[] inspectIds, Integer dataState) {
        JSONObject json = inspectService.definedInspect(inspectIds, dataState);
        return json;
    }

    /**
     * 删除
     *
     * @param inspectIds, dataState
     * @return com.indusfo.spc.vo.JSONObject
     */
    @RequestMapping(value="/deleteInspect", method= RequestMethod.POST)
    @SystemControllerLog(description="删除点检项目")
    @ResponseBody
    public JSONObject deleteInspect(Long[] inspectIds, Integer dataState) {
        dataState = 2;
        JSONObject json = inspectService.definedInspect(inspectIds, dataState);
        return json;
    }

}
